package hihocoder;
import java.util.Scanner;

/**
 * 
 */

/**
 * @author zhongfang
 *
 */
public class 出勤记录I {

	public static boolean qualified(String string) {
		boolean result=true;
		int lateCount=0;
		int absenceCount=0;
		boolean constantL=false;
		for (int i = 0; i < string.length(); i++) {
			if (string.charAt(i)=='L') {
				if(!constantL){//第一个连续的L开始
					constantL=true;
					lateCount=1;
				}else {
					lateCount++;
					if(lateCount==3)
						return false;
				}
			}else{
				constantL=false;//重新开始计数
				lateCount=0;
				 if(string.charAt(i)=='A'){
					 absenceCount++;
						if(absenceCount==2){
							return false;
						}
					}else {
						
					}
				 }
			}
			
		return true;
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		int n=scanner.nextInt();
		scanner.nextLine();
		while (n>0) {
			String string=scanner.nextLine();
			System.out.println(qualified(string)?"YES":"NO");
			n--;
		}
	}

}
